
<html>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
var oldPass="";
$(document).ready(function(){
	//alert(request('winType'));
	if(request('winType')==2){
		//alert(request('realName'));
		if(request('userName')=="admin"){
			$("#userName").attr("readonly","readonly");
		}
		$("#realName").val(request('realName'));
		$("#userName").val(request('userName'));
		$("#userPass").val(request('userPass'));
		$("#userPass").val('');
		oldPass=request('userPass');
	}
	else{
		$("#realName").val('');
		$("#userName").val('');
		$("#userPass").val('');
		setTimeout( function(){
			$("#realName").val('');
			$("#userName").val('');
			$("#userPass").val('');
			}, 200 );//延迟500ms
	}
})
function updateUser(){
	var startTime;
	$.post('../../user/listWorkerNoTask.action',{startTime:startTime},function(data,status){
		data = data.replaceAll('"M"','"男"');
		data = data.replaceAll('"W"','"女"');
		//alert(data);
		var localData=eval(data);    		
		gridObj = $.fn.bsgrid.init('searchTable', {
	        //url: '../../taskissuance/listWorkerNoTask.action',
	        //url: 'http://bsgrid.oschina.mopaas.com/examples/grid/data/json.jsp',
	        localData: localData,
	        // autoLoad: false,
	        pageSizeSelect: true,
	        pageSize: 10
	    });

	    
	});
}
function closeLayer(){
	//alert(request('ss'));return;
	 parent.layer.closeAll();
}
function addUser(){
	
	var realName=$("#realName").val();
	var userName=$("#userName").val();
	var userPass=$("#userPass").val();
	if(realName==""||userName==""||userPass==""){
		alert("请将参数填写完整！");
		return;
	}
if(request('winType')==1){
	$.post('../../user/save.action',{realName:realName,userName:userName,userPass:userPass},function(data,status){
		//alert(data);
		//var localData=eval(data);  
		//alert(status);
		if(status=="success"){
			parent.location.reload(true); 
			parent.layer.closeAll();
		}
	});
	}
else if (request('winType')==2){
	var paras=null;
	if(userPass==oldPass){
		paras={id:request('id'),realName:realName,userName:userName,userPass:userPass};
	}
	else{
		paras={id:request('id'),realName:realName,userName:userName,userPass:userPass};
	}
	$.post('../../user/save.action',paras,function(data,status){
		//alert(data);
		//var localData=eval(data);  
		//alert(status);
		if(status=="success"){
			parent.location.reload(true); 
			parent.layer.closeAll();
		}
	});
}
	
}
function request(strParame) { 
	var args = new Object( ); 
	var query = location.search.substring(1); 

	var pairs = query.split("&"); // Break at ampersand 
	for(var i = 0; i < pairs.length; i++) { 
	var pos = pairs[i].indexOf('='); 
	if (pos == -1) continue; 
	var argname = pairs[i].substring(0,pos); 
	var value = pairs[i].substring(pos+1); 
	value = decodeURIComponent(value); 
	args[argname] = value; 
	} 
	return args[strParame]; 
	} 
</script>
<body>
	科室名称:<input id="realName" type="text" placeholder="科室名称">
	<br>
	<br> 
	用户名:<input id="userName" type="text" placeholder="用户名">
	<br>
	<br> 
	密码:<input id="userPass" type="password" placeholder="密码">
	<br>
	<br>
	<button onclick="addUser();">确认</button>
	<button onclick="closeLayer()">取消</button>
</body>

</html>